package com.kancy.demo.delay.queue.redis.handler;

import com.kancy.delay.queue.redis.handler.DelayQueueMessageHandler;
import com.kancy.delay.queue.redis.handler.EmptyDelayQueueMessageHandler;
import com.kancy.delay.queue.redis.message.DelayMessage;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * <p>
 * TestRetryDelayQueueMessageHandler
 * <p>
 *
 * @author: kancy
 * @date: 2020/3/5 22:07
 **/
@RequiredArgsConstructor
@Component
public class TestSleepTaskDelayQueueMessageHandler implements DelayQueueMessageHandler {

    private final EmptyDelayQueueMessageHandler emptyDelayQueueMessageHandler;
    /**
     * 处理延迟消息
     *
     * @param delayMessage
     */
    @Override
    public void process(DelayMessage delayMessage) {
        try {
            TimeUnit.SECONDS.sleep(3);
            emptyDelayQueueMessageHandler.process(delayMessage);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
